<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" href="${ctx}/css/sapar.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css"/>
    <script type="text/javascript" src="${ctx}/js/jquery.js"></script>
    <script type="text/javascript" src="${ctx}/js/sapar.js"></script>
    <script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
    <script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
    <script type="text/javascript" src="${ctx}/assets/laydate/laydate.js"></script>
    <script type="text/javascript" src="${ctx}/assets/laydate/laydate.js"></script>
    <script src="${ctx}/js/share.js" type="text/javascript"></script>
    <script src="${ctx}/js/mask.js" type="text/javascript"></script>

    <link rel="stylesheet" href="${ctx}/css/jquery-ui-1.9.2.custom.css" type="text/css">
    <script src="${ctx}/js/jquery-ui-1.9.2.custom.js" type="text/javascript" language="javascript"></script>

    <title>计费统计</title>
    <style>
        .co_table table {
            width: 100%;
            text-align: center;
        }

        td {
            text-align: center;
        }

        .co_table table tr {
            height: 35px;
            line-height: 35px;
            background: #fff !important;
        }

        .table table tr:hover {
            background: #fff !important;
        }
    </style>
</head>
<body>
<div id="saper-container">
    <div class="subfiled clearfix">
        <h2>计费统计</h2>
    </div>
    <div class="subfiled-content">
        <div class="search-box clearfix">
            <%-- <div class="kv-item clearfix" id="txt">
                <label>科室：</label>
                <div class="kv-item-content" id="txt1">
                    <input type="text" name="searchTxt" placeholder="科室" class="search_text" value="${keshi }"  onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                </div>
            </div> --%>
            <div class="kv-item clearfix">
                <label>选择科室：</label>
                <select name="chaxunKeshi" onchange="signPro('0')" id="sel">
                    <c:if test="${dep != null }">
                        <option value="${dep.departmentId }">${dep.departmentName}</option>
                        <option value="">请选择</option>
                    </c:if>
                    <c:if test="${dep == null }">
                        <option value="">请选择</option>
                    </c:if>
                    <c:if test="${department != null}">
                        <c:forEach items="${department }" var="pro">
                            <c:if test="${pro.departmentId != 16 && pro.departmentId != 17 }">
                                <c:if test="${pro.departmentId!=dep.departmentId}">
                                    <option value="${pro.departmentId}">${pro.departmentName}</option>
                                </c:if>
                            </c:if>
                        </c:forEach>
                    </c:if>
                </select>
            </div>
            <div class="kv-item clearfix" style="margin-left: 20px; ">

                <input style="padding-left: 32px ;padding-right: 8px"  name="time" id="time" type="text" class="ui-datepicker-time"   />
                <div class="ui-datepicker-css">
                    <div class="ui-datepicker-quick">
                        <p>快捷日期<a class="ui-close-date">X</a></p>
                        <div>
                            <input @click="timeChangeFun"  class="ui-date-quick-button" type="button" value="今天" alt="0"  name=""/>
                            <input @click="timeChangeFun" class="ui-date-quick-button" type="button" value="昨天" alt="-1" name=""/>
                            <input @click="timeChangeFun" class="ui-date-quick-button" type="button" value="7天内" alt="-6" name=""/>
                            <input @click="timeChangeFun" class="ui-date-quick-button" type="button" value="14天内" alt="-13" name=""/>
                            <input @click="timeChangeFun" class="ui-date-quick-button" type="button" value="30天内" alt="-29" name=""/>
                            <input @click="timeChangeFun" class="ui-date-quick-button" type="button" value="60天内" alt="-59" name=""/>
                        </div>
                    </div>
                    <div class="ui-datepicker-choose">
                        <p>自选日期</p>
                        <div class="ui-datepicker-date">
                            <input @click="timeChangeFun" name="startDate" id="startDate" class="startDate" readonly value="2014/12/20" type="text">
                            -
                            <input @click="timeChangeFun" name="endDate" id="endDate" class="endDate" readonly  value="2014/12/20" type="text" disabled  onchange="datePickers()">

                        </div>
                    </div>
                </div>

                <%--<div class="kv-item-content">--%>
                    <%--<span>&nbsp;&nbsp;&nbsp;起始时间:</span>--%>
                    <%--<input type="text" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" id="st"--%>
                           <%--name="startTime"--%>
                           <%--value="<fmt:formatDate value='${st}' type='date' pattern='yyyy-MM-dd HH:mm:ss'/>"--%>
                           <%--readonly="readonly"/>--%>
                    <%--<span>&nbsp;&nbsp;&nbsp;终止时间:</span>--%>
                    <%--<input type="text" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" id="et"--%>
                           <%--name="endTime"--%>
                           <%--value="<fmt:formatDate value='${et}' type='date' pattern='yyyy-MM-dd HH:mm:ss'/>"--%>
                           <%--readonly="readonly"/>--%>
                <%--</div>--%>
            </div>
            <div id="aa"><a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="chaxun">查询</a></div>
            <div><a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="daochu">厂家费用导出</a></div>
                <div><a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="linchuangdaochu">临床费用导出</a></div>
                <div><a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="linchuangMingxidaochu">临床明细费用导出</a></div>
        </div>
        <div class="co_table table">
            <table style="border-collapse: collapse;">
                <thead>
                <tr>
                    <th>科室</th>
                    <th>项目</th>
                    <th>品名</th>
                    <th>数量</th>
                    <th>单价(元)</th>
                    <th>总价(元)</th>
                    <th>合计(元)</th>
                </tr>
                </thead>
                <tr>
                    <td rowspan="5" style="text-align: center;border-right:1px dotted #c7c7c7;">
                        <c:if test="${not empty dep }">${dep.departmentName }</c:if>
                        <c:if test="${empty dep }">计费科室名</c:if>
                    </td>
                    <td style="text-align: center;">一次无菌物品</td>
                    <td colspan="4" style="text-align: center;">
                        <table style="border:0px;">
                            <c:if test="${!empty wujunMap}">
                                <c:forEach items="${wujunMap}" var="wujun">
                                    <c:if test="${wujun.value.proType == 0}">
                                        <tr>
                                            <td width="20%;"><c:out value="${wujun.value.productName }"></c:out></td>
                                            <td width="15%;"><c:out value="${wujun.value.num }"></c:out></td>
                                            <td width="30%;"><fmt:formatNumber type="number"
                                                                               value="${wujun.value.productPrice}"
                                                                               maxFractionDigits="2"></fmt:formatNumber></td>
                                            <td width="30%;"><fmt:formatNumber type="number"
                                                                               value="${wujun.value.totalPrice}"
                                                                               maxFractionDigits="2"></fmt:formatNumber></td>
                                        </tr>
                                    </c:if>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty wujunMap }">
                                <span style="color:red;">无费用</span>
                            </c:if>
                        </table>
                    </td>
                    <td style="text-align: center;">
                        <c:if test="${wujunTotal != null }"><fmt:formatNumber type="number" value="${wujunTotal}"
                                                                              maxFractionDigits="2"></fmt:formatNumber></c:if>
                        <c:if test="${wujunTotal == null }">0</c:if>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center;">一次清洁物品</td>
                    <td colspan="4" style="text-align: center;">
                        <table style="border:0px;">
                            <c:if test="${!empty qingjieMap}">
                                <c:forEach items="${qingjieMap}" var="qingjie">
                                    <c:if test="${qingjie.value.proType == 1}">
                                        <tr>
                                            <td width="20%;"><c:out value="${qingjie.value.productName}"></c:out></td>
                                            <td width="15%;"><c:out value="${qingjie.value.num}"></c:out></td>
                                            <td width="30%;"><fmt:formatNumber type="number"
                                                                               value="${qingjie.value.productPrice}"
                                                                               maxFractionDigits="2"></fmt:formatNumber></td>
                                            <td width="30%;"><fmt:formatNumber type="number"
                                                                               value="${qingjie.value.totalPrice}"
                                                                               maxFractionDigits="2"></fmt:formatNumber></td>
                                        </tr>
                                    </c:if>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty qingjieMap}">
                                <span style="color: red;">无费用</span>
                                   </c:if>
                        </table>
                    </td>
                    <td>
                        <c:if test="${qingjieTotal != null }"><fmt:formatNumber type="number" value="${qingjieTotal}"
                                                                                maxFractionDigits="2"></fmt:formatNumber></c:if>
                        <c:if test="${qingjieTotal == null }">0</c:if>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center;">无菌包成本费</td>
                    <td colspan="4" style="text-align: center;">
                        <table style="border:0px;">
                            <c:if test="${!empty chengbenMap }">
                                <c:forEach items="${chengbenMap }" var="chengben">
                                    <tr>
                                        <td width="20%;"><c:out value="${chengben.value.productName }"></c:out></td>
                                        <td width="15%;"><c:out value="${chengben.value.num }"></c:out></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${chengben.value.productPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${chengben.value.totalPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty chengbenMap }">
                                <span style="color: red;margin-left: -13px;">无费用</span>
                            </c:if>
                        </table>
                    </td>
                    <td style="text-align: center;">
                        <c:if test="${chengbenTotal != null }"><fmt:formatNumber type="number" value="${chengbenTotal}"
                                                                                 maxFractionDigits="2"></fmt:formatNumber></c:if>
                        <c:if test="${chengbenTotal == null }">0</c:if>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center;">缺失费用</td>
                    <td colspan="4" style="text-align: center;">
                        <table style="border:0px;">
                            <c:if test="${!empty queshiMap }">
                                <c:forEach items="${queshiMap }" var="queshi">
                                    <tr>
                                        <td width="20%;"><c:out value="${queshi.value.productName }"></c:out></td>
                                        <td width="15%;"><c:out value="${queshi.value.num }"></c:out></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${queshi.value.productPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${queshi.value.totalPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty queshiMap }">
                                <span style="color: red;margin-left: -13px;">无费用</span>
                            </c:if>
                        </table>
                    </td>
                    <td style="text-align: center;">
                        <c:if test="${queshiTotal != null }"><fmt:formatNumber type="number" value="${queshiTotal}"
                                                                               maxFractionDigits="2"></fmt:formatNumber></c:if>
                        <c:if test="${queshiTotal == null }">0</c:if>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center;">周转费</td>
                    <td colspan="4" style="text-align: center;">
                        <table style="border:0px;">
                            <c:if test="${!empty zhouzhuanMap }">
                                <c:forEach items="${zhouzhuanMap }" var="zhouzhuan">
                                    <tr>
                                        <td width="20%;"><c:out value="${zhouzhuan.value.productName }"></c:out></td>
                                        <td width="15%;"><c:out value="${zhouzhuan.value.num }"></c:out></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${zhouzhuan.value.productPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                        <td width="30%;"><fmt:formatNumber type="number"
                                                                           value="${zhouzhuan.value.totalPrice}"
                                                                           maxFractionDigits="2"></fmt:formatNumber></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty zhouzhuanMap}">
                                <span style="color: red;">无费用</span>
                                   </c:if>
                        </table>
                    </td>
                    <td style="text-align: center;">
                        <c:if test="${zhouzhuanTotal == null }">0</c:if>
                        <c:if test="${zhouzhuanTotal != null }"><fmt:formatNumber type="number"
                                                                                  value="${zhouzhuanTotal}"
                                                                                  maxFractionDigits="2"></fmt:formatNumber></c:if>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="${ctx}/js/vue.min.js"></script>
<script type="text/javascript">
    $(function () {

        $("#chaxun").click(function () {
            var btn = true;
//            var starttime = $("#st").val();
//            var endtime = $("#et").val();
//            var start = new Date(starttime.replace("-", "/").replace("-", "/"));
//            var end = new Date(endtime.replace("-", "/").replace("-", "/"));
            debugger
            var time = $("#time").val();
            var times = time.split("一");
            if(times.length==2){
                var starttime = times[0];
                var endtime =times[1];
            }
            var txt = $("#sel").val();
//            if (end < start) {
//                alert("终止时间不能在起始时间之前");
//                btn = false;
//            }
            /* if(isNullOrEmpty(txt)){
             alert("请输入科室");
             btn = false;
             } */
            if (btn) {
                window.location.href = "${ctx}/tongji/jifeitongji.do?txt=" + txt + "&startTime=" + starttime + "&endTime=" + endtime;
            }
        });

        $("#daochu").click(function () {
            var btn = true;
//            var starttime = $("#st").val();
//            var endtime = $("#et").val();
            var time = $("#time").val();
            var times = time.split("一");


            debugger
            if(times.length==2){
                var start = times[0];
                var end = times[1];
            }
//            var start = new Date(starttime.replace("-", "/").replace("-", "/"));
//            var end = new Date(endtime.replace("-", "/").replace("-", "/"));
//            var txt = $("#sel").val();
            if (end < start) {
                alert("终止时间不能在起始时间之前");
                btn = false;
            }
//            if (isNullOrEmpty(txt)) {
//                alert("请选择科室");
//                btn = false;
//            }
            <%--if (btn) {--%>
                <%--window.location.href = "${ctx}/tongji/jifeidaochu.do?txt=" + txt + "&startTime=" + starttime + "&endTime=" + endtime;--%>
                <%--;--%>
            <%--}--%>
            if (btn) {
                window.location.href = "${ctx}/tongji/costBycangjia?startTime=" + start + "&endTime=" + end;
                ;
            }
        });

        $("#linchuangdaochu").click(function () {
            var btn = true;
            var time = $("#time").val();
            var times = time.split("一");
            if(times.length==2){
                var start = times[0];
                var end = times[1];
            }
            if (btn) {
                window.location.href = "${ctx}/tongji/costBylinChuangTotle?startTime=" + start + "&endTime=" + end;
                ;
            }
        });
        $("#linchuangMingxidaochu").click(function () {
            var btn = true;
            var time = $("#time").val();
            var times = time.split("一");
            if(times.length==2){
                var start = times[0];
                var end = times[1];
            }
            if (btn) {
                window.location.href = "${ctx}/tongji/costBylinChuangMingxi?startTime=" + start + "&endTime=" + end;
                ;
            }
        });

    });
    function isNullOrEmpty(strVal) {
        strVal = strVal.replace(/(^\s*)|(\s*$)/g, "");
        if (strVal == '' || strVal == null || strVal == undefined) {
            return true;
        } else {
            return false;
        }
    }
</script>
</html>